{% extends "_layouts/examples.html" %}
{% block title %}Code Snippet / Syntax highlight{% endblock %}

{% block standalone_css %}patterns_code-snippet{% endblock %}

{% block content %}
<div class="p-code-snippet">
  <div class="p-code-snippet__header">
    <h5 class="p-code-snippet__title">Python</h5>
  </div>
<pre class="p-code-snippet__block language-python"><code>class DiscourseAPI:
  """
  Retrieve information from a Discourse installation
  through its API
  """

  def __init__(self, base_url, session, api_key=None, api_username=None):
      """
      @param base_url: The Discourse URL (e.g. https://discourse.example.com)
      """

      self.base_url = base_url.rstrip("/")
      self.session = session

      if api_key and api_username:
          self.session.headers = {
              "Api-Key": api_key,
              "Api-Username": api_username,
          }</code></pre>

</div>

<div class="p-code-snippet">
  <div class="p-code-snippet__header">
    <h5 class="p-code-snippet__title">Yaml (numbered)</h5>
  </div>
  <pre class="p-code-snippet__block--numbered language-yaml"><code><span class="p-code-snippet__line">name: super-cool-app</span>
<span class="p-code-snippet__line">version: "1.0"</span>
<span class="p-code-snippet__line">summary: Super Cool App</span>
<span class="p-code-snippet__line">description: |</span>
<span class="p-code-snippet__line">    Super Cool App that does everything! […]</span>
<span class="p-code-snippet__line">confinement: strict</span>
<span class="p-code-snippet__line">base: core18</span>
<span class="p-code-snippet__line">parts:</span>
<span class="p-code-snippet__line">  super-cool-app:</span>
<span class="p-code-snippet__line">    plugin: flutter</span>
<span class="p-code-snippet__line">    source: https://github.com/kenvandine/super-cool-app.git</span>
<span class="p-code-snippet__line">    flutter-target: lib/main.dart</span>
<span class="p-code-snippet__line">apps:</span>
<span class="p-code-snippet__line">  super-cool-app:</span>
<span class="p-code-snippet__line">    command: super_cool_app</span>
<span class="p-code-snippet__line">    extensions: [flutter-dev]</span></code></pre>
</div>

<div class="p-code-snippet">
  <div class="p-code-snippet__header">
    <h5 class="p-code-snippet__title">Manual highlighting</h5>
  </div>
  <pre class="p-code-snippet__block">npm install --save-dev vanilla-framework
<span class="token keyword">export</span> SASS_PATH=`pwd`/node_modules:${SASS_PATH}

<span class="token comment">// Add to your main build scss file the following line</span>
<span class="token atrule">@import</span> <span class="token string">'vanilla-framework'</span></code></pre>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/components/prism-core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/keep-markup/prism-keep-markup.min.js"></script>
{% endblock %}
